package task2;

import java.util.Scanner;

public class test4 {

    static Scanner input=new Scanner(System.in);
    static StringBuilder result=new StringBuilder("");
    static String template;
    static boolean isInsert=true;
    static int index=0;


    public static void main(String[] args) {

        template= input.nextLine();
        System.out.println(progress());
    }
    private static String progress(){

        for(int i=0;i<template.length();i++){
            match(template.charAt(i));
        }
        return result.toString();
    }
    private static void match(char ch){
        switch (ch){
            case '[':{
                index=0;
            }break;
            case ']':{
                index=result.length()==0?0:result.length();
            }break;
            case '{':{
                if(index>0){
                    index--;
                }
            }break;
            case '}':{
                if(index<result.length()){
                    index++;
                }
            }break;
            case '-':{
                isInsert=!isInsert;
            }break;
        }
        if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||ch==' '){
            if (isInsert) {
                result.insert(index,ch);
            } else {
                result.replace(index, index+1, String.valueOf(ch));
            }
            index++;
        }
        else if(ch=='='){
            if(index>0){
                index--;
            }
            result.delete(index,index+1);
        }
    }
}
